module.exports = Object.freeze({
    data:{
        host: process.env.myhost,
        port: process.env.myport,
        user: process.env.myuser,
        password: process.env.mypass,
        database: 'node',
        connectionLimit: 1000,
        connectTimeout: 60 * 1000,
        acquireTimeout: 60 * 1000,
        timeout: 60 * 1000
        
    },
    mapper:{
        login:{ 
            sql:'select id,login_name,user_name from user where login_name = ? and password = ?',
            param:obj=>{
                let user = JSON.parse(obj);
                return [user['name'], user['password']];
            }
        },
        test:{
            sql:'',
            param:obj=>obj
        },
        intro:{
            sql:'select  id,k,val from intro',
            param:obj=>obj
        },
        education:{
            sql:'select id,name,major,degree,time,image from education',
            param:obj=>obj
        },
        works:{
            sql:'select id,name,position,time,result from works',
            param:obj=>obj
        },
        skill:{
            sql:'select id ,name,jn,icn from skill',
            param:obj=>obj
        },
        updateIntro:{
            sql:'update intro set val = ? where id = ?',
            param:obj=>{
                let info = JSON.parse(obj);
                return [info['val'], info['id']];
            }
        },
        insertIntro:{
            sql:'insert into intro (k,val) values(? , ?)',
            param:obj=>{
                let info = JSON.parse(obj);
                return [info['k'],info['val']];
            }
        },
        delIntro:{
            sql:'delete from intro where id in (?)',
            param:obj=>{
                let info = JSON.parse(obj);
                return [info['ids']];
            }
        },
        insertEducation:{
            sql:'insert into education(name,major,degree,time,image) values (?,?,?,?,?)',
            param:obj=>{
                let info = JSON.parse(obj);
                console.log(info)
                return [info['name'],info['major'],info['degree'],info['time'],info['image']];
            }
        },
        updateEducation:{
            sql:'update  education set name=? ,major=?,degree=?,time=?,image=? where id =?',
            param:obj=>{
                let info = JSON.parse(obj);
                return [info['name'],info['major'],info['degree'],info['time'],info['image'],info['id']];
            }
        },
        delEducation:{
            sql:'delete from education where id in (?)',
            param:obj=>{
                let info = JSON.parse(obj);
                return [info['ids']];
            }
        },
        insertWork:{
            sql:'insert into works(name,position,time,result) values (?,?,?,?)',
            param:obj=>{
                let info = JSON.parse(obj);
                return [info['name'],info['position'],info['time'],info['result']];
            }
        },
        updateWork:{
            sql:'update  works set name = ?,position = ?,time= ? ,result=? where id = ?',
            param:obj=>{
                let info = JSON.parse(obj); 
                return [info['name'],info['position'],info['time'],info['result'],info['id']];
            }
        },
        delWork:{
            sql:'delete from works where id in (?)',
            param:obj=>{
                let info = JSON.parse(obj); 
                return [info['ids']];
            }
        },
        insertSkill:{
            sql:'insert into skill(name,jn,icn) values (?,?,?)',
            param:obj=>{
                let info = JSON.parse(obj);
                return [info['name'],info['jn'],info['icn']];
            }
        },
        updateSkill:{
            sql:'update  skill set name = ?,jn = ?,icn= ? where id = ?',
            param:obj=>{
                let info = JSON.parse(obj); 
                return [info['name'],info['jn'],info['icn'],info['id']];
            }
        },
        delSkill:{
            sql:'delete from skill where id in (?)',
            param:obj=>{
                let info = JSON.parse(obj); 
                return [info['ids']];
            }
        },
    }
});